//
//  HJAppleAuthenticator.h
//  GoogleLoginICloud
//
//  Created by lx on 2024/1/5.
//

#import <Foundation/Foundation.h>
#import <AuthenticationServices/AuthenticationServices.h>

NS_ASSUME_NONNULL_BEGIN

@class UIWindow, AppleAuthenticator;


@interface HJAppleUser : NSObject

@property (nonatomic, strong, readonly) NSString *userID;
@property (nonatomic, strong, readonly, nullable) NSString *fullName;
@property (nonatomic, strong, readonly, nullable) NSString *email;
@property (nonatomic, strong, readonly) NSString *identityToken;
@property (nonatomic, strong, readonly) NSString *realUserStatus;

@end


@interface HJAppleSignInResult : NSObject

@property (nonatomic, strong, readonly) NSString *authorizationCode;
@property (nonatomic, strong, readonly) HJAppleUser *user;


@end


@protocol AppleAuthenticatorDelegate <NSObject>

@optional

- (void)appleAuthenticator:(AppleAuthenticator *)manager didCompleteWithError:(NSError *)error;
- (void)appleAuthenticator:(AppleAuthenticator *)manager didCompleteWithResult:(HJAppleSignInResult *)result;
- (void)appleAuthenticator:(AppleAuthenticator *)manager appleIdStateChanged:(NSDictionary *)info;


@end


@interface AppleAuthenticator : NSObject
 
@property (nonatomic, weak) id <AppleAuthenticatorDelegate> delegate;

- (void)signInWithWithWindow:(UIWindow *)window;
+ (void)getCredentialStateWithUserId:(NSString *)userId completion:(void (^)(ASAuthorizationAppleIDProviderCredentialState credentialState, NSError * _Nullable error))completion API_AVAILABLE(ios(13.0));



@end

NS_ASSUME_NONNULL_END
